package com.ycz.algorithm.utils.graph.adjacencylist;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yancz
 * @ClassName Vertex
 * @description: // 自定义顶点类
 * @date 2025-01-09 16:16:47
 * @version: 1.0
 */
public class Vertex {

    public int val; // 顶点值

    // 构造方法
    public Vertex(int val) {
        this.val = val;
    }

    // 值数组转为顶点类Vertex数组
    public static Vertex[] arrayToVertexArray(int[] array) {
        Vertex[] vertexArray = new Vertex[array.length];
        for (int i = 0; i < array.length; i++) {
            vertexArray[i] = new Vertex(array[i]);
        }
        return vertexArray;
    }

    // 顶点类列表转为值列表
    public static List<Integer> vertexToList(List<Vertex> vertexList) {
        List<Integer> list = new ArrayList<>();
        for (Vertex vertex : vertexList) {
            list.add(vertex.val);
        }
        return list;
    }

}
